package com.bifrost.task;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@JobHandler(value="demoJobHandler")
@Component
public class DemoJobHandler extends IJobHandler {

	public static final Logger LOGGER = LoggerFactory.getLogger(DemoJobHandler.class);

	@Override
    public ReturnT<String> execute(String param) throws Exception {
		XxlJobLogger.log("XXL-JOB, Hello World.");

		for (int i = 0; i < 5; i++) {
			XxlJobLogger.log("beat at:" + i);
			TimeUnit.SECONDS.sleep(2);
			XxlJobLogger.log(i+"");
		}
		LOGGER.info("执行完成");
		XxlJobLogger.log("执行完成");
		return SUCCESS;
	}

}